package main

import (
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"github.com/jinzhu/gorm"
)

func main() {
	db, err := gorm.Open("mysql", "root:root@(127.0.0.1)/test?charset=utf8&parseTime=True&loc=Local")
	if err != nil {
		panic(err)
	}
	defer db.Close()
	stu := Student{
		Name:     "张三",
		Sex:      "男",
		Birthday: "2020-02-02",
	}
	//插入记录
	rows := db.Table("tb_stu").Save(&stu)
	//db.Create(&stu)
	fmt.Println(rows)
}
